﻿<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="SalaryTotal.aspx.cs" Inherits="KPI_SYSTEM.SalaryPage.SalaryTotal" %>

<!DOCTYPE html>
<html>
<head runat="server">
    <title></title>
    <style>
        
    </style>
</head>
<body>
    <form id="form1" runat="server">
        <f:PageManager ID="PageManager1" runat="server" />
        <f:Form ID="Form2" IsFluid="true" CssClass="blockpanel" BodyPadding="5 5 0 5" LabelAlign="Left" ShowHeader="false"
            Title="查询" runat="server">
            <Rows>
                <f:FormRow ColumnWidths="15% 15% 8% 8% 8% 8%">
                    <Items>
                        <f:TextBox runat="server" ID="tbxNameSerach" Label="名称"></f:TextBox>
                        <f:Button ID="btnSearch" Text="搜索" Icon="Magnifier" runat="server" OnClick="btnSearch_Click"></f:Button>
                    </Items>
                </f:FormRow>
            </Rows>
        </f:Form>
        <f:TabStrip ID="TabStrip1" IsFluid="true" CssClass="blockpanel"  ShowBorder="true" TabPosition="Top" ActiveTabIndex="0"
            runat="server">
            <Tabs>
                <f:Tab Title="发款合计项" ID="Tab1" BodyPadding="10px" runat="server">
                    <Items>
                        <f:Grid ID="GridSalary" IsFluid="true" CssClass="blockpanel" ShowBorder="true" ShowHeader="false" EnableCollapse="false"
                            runat="server" DataKeyNames="REC_ID" AllowCellEditing="false" 
                            DataIDField="REC_ID" Title="发款合计条目" OnRowCommand="GridSalary_RowCommand" OnPreRowDataBound="GridSalary_PreRowDataBound">
                            <Toolbars>
                                <f:Toolbar ID="Toolbar2" Position="Top" runat="server">
                                    <Items>
                                        <f:Button ID="btnNew" Text="新增" Icon="Add" EnablePostBack="false" runat="server">
                                            <Listeners>
                                                <f:Listener Event="click" Handler="onNewButtonClick" />
                                            </Listeners>
                                        </f:Button>
                                    </Items>
                                </f:Toolbar>
                            </Toolbars>
                            <Columns>
                                <f:TemplateField Width="60px">
                                    <ItemTemplate>
                                        <asp:Label ID="Label1" runat="server" Text='<%# Container.DataItemIndex + 1 %>'></asp:Label>
                                    </ItemTemplate>
                                </f:TemplateField>
                                <f:RenderField Width="150px" ColumnID="TOTAL_ITEM_NAME" DataField="TOTAL_ITEM_NAME"
                                    HeaderText="条目名称">
                                </f:RenderField>
                                <f:RenderField Width="150px" ColumnID="TOTAL_ITEM_CODE" DataField="TOTAL_ITEM_CODE"
                                    HeaderText="条目编码">
                                </f:RenderField>
                                <f:RenderField Width="100px" ColumnID="TOTAL_ITEM_SEQ" DataField="TOTAL_ITEM_SEQ"
                                    HeaderText="排序">
                                </f:RenderField>
                                <f:RenderField Width="150px" ColumnID="TOTAL_ITEM_TYPE_NAME" DataField="TOTAL_ITEM_TYPE_NAME"
                                    HeaderText="条目类别">
                                </f:RenderField>
                                <f:RenderField Width="150px" ColumnID="TOTAL_ITEM_REMARK" DataField="TOTAL_ITEM_REMARK"
                                    HeaderText="条目备注">
                                </f:RenderField>
                                <f:RenderField Width="150px" ColumnID="CREATE_TIME" DataField="CREATE_TIME" FieldType="Date"
                                    Renderer="Date" RendererArgument="yyyy-MM-dd"
                                    HeaderText="创建时间">
                                </f:RenderField>
                                <f:RenderField Width="150px" ColumnID="CREATE_USER_NAME" DataField="CREATE_USER_NAME"
                                    HeaderText="创建人">
                                </f:RenderField>
                                <f:RenderField Hidden="true" ColumnID="TOTAL_ITEM_TYPE" DataField="TOTAL_ITEM_TYPE"
                                    HeaderText="条目类别ID">
                                </f:RenderField>
                                 <f:RenderField Hidden="true" ColumnID="TOTAL_ITEM_MAPPING" DataField="TOTAL_ITEM_MAPPING"
                                    HeaderText="对应字典ID">
                                </f:RenderField>
                                <f:LinkButtonField ColumnID="Edit" Width="50px" EnablePostBack="false"
                                    Icon="Pencil" />
                                <f:LinkButtonField Width="50px" ConfirmText="删除选中行？" ConfirmTarget="Top"
                                    CommandName="Delete" Icon="Delete" />
                            </Columns>
                        </f:Grid>
                    </Items>
                </f:Tab>
                <f:Tab Title="扣款合计项" ID="Tab2" BodyPadding="10px" runat="server">
                    <Items>
                        <f:Grid ID="GridDeduct" IsFluid="true" CssClass="blockpanel" ShowBorder="true" ShowHeader="false" EnableCollapse="false"
                            runat="server" DataKeyNames="REC_ID" AllowCellEditing="false"
                            DataIDField="REC_ID" Title="扣款合计条目" OnRowCommand="GridDeduct_RowCommand" OnPreRowDataBound="GridDeduct_PreRowDataBound">
                            <Toolbars>
                                <f:Toolbar ID="Toolbar3" Position="Top" runat="server">
                                    <Items>
                                        <f:Button ID="Button1" Text="新增" Icon="Add" EnablePostBack="false" runat="server">
                                            <Listeners>
                                                <f:Listener Event="click" Handler="onNewButtonClick" />
                                            </Listeners>
                                        </f:Button>
                                    </Items>
                                </f:Toolbar>
                            </Toolbars>
                             <Columns>
                                <f:TemplateField Width="60px">
                                    <ItemTemplate>
                                        <asp:Label ID="Label2" runat="server" Text='<%# Container.DataItemIndex + 1 %>'></asp:Label>
                                    </ItemTemplate>
                                </f:TemplateField>
                                <f:RenderField Width="150px" ColumnID="TOTAL_ITEM_NAME" DataField="TOTAL_ITEM_NAME"
                                    HeaderText="条目名称">
                                </f:RenderField>
                                <f:RenderField Width="150px" ColumnID="TOTAL_ITEM_CODE" DataField="TOTAL_ITEM_CODE"
                                    HeaderText="条目编码">
                                </f:RenderField>
                                <f:RenderField Width="100px" ColumnID="TOTAL_ITEM_SEQ" DataField="TOTAL_ITEM_SEQ"
                                    HeaderText="排序">
                                </f:RenderField>
                                <f:RenderField Width="150px" ColumnID="TOTAL_ITEM_TYPE_NAME" DataField="TOTAL_ITEM_TYPE_NAME"
                                    HeaderText="条目类别">
                                </f:RenderField>
                                <f:RenderField Width="150px" ColumnID="TOTAL_ITEM_REMARK" DataField="TOTAL_ITEM_REMARK"
                                    HeaderText="条目备注">
                                </f:RenderField>
                                <f:RenderField Width="150px" ColumnID="CREATE_TIME" DataField="CREATE_TIME" FieldType="Date"
                                    Renderer="Date" RendererArgument="yyyy-MM-dd"
                                    HeaderText="创建时间">
                                </f:RenderField>
                                <f:RenderField Width="150px" ColumnID="CREATE_USER_NAME" DataField="CREATE_USER_NAME"
                                    HeaderText="创建人">
                                </f:RenderField>
                                <f:RenderField Hidden="true" ColumnID="TOTAL_ITEM_TYPE" DataField="TOTAL_ITEM_TYPE"
                                    HeaderText="条目类别ID">
                                </f:RenderField>
                                  <f:RenderField Hidden="true" ColumnID="TOTAL_ITEM_MAPPING" DataField="TOTAL_ITEM_MAPPING"
                                    HeaderText="对应字典ID">
                                </f:RenderField>
                                <f:LinkButtonField ColumnID="Edit" Width="50px" EnablePostBack="false"
                                    Icon="Pencil" />
                                <f:LinkButtonField Width="50px" ConfirmText="删除选中行？" ConfirmTarget="Top"
                                    CommandName="Delete" Icon="Delete" />
                            </Columns>
                        </f:Grid>
                    </Items>
                </f:Tab>
            </Tabs>
            <Listeners>
                <f:Listener Event="tabchange" Handler="onTabChange" />
            </Listeners>
        </f:TabStrip>


        <f:Window ID="Window1" Title="编辑信息" Hidden="true" EnableIFrame="false"
            EnableMaximize="true" Target="Self" EnableResize="true" runat="server"
            IsModal="true" Width="650px">
            <Items>
                <f:SimpleForm ID="SimpleForm1" runat="server" ShowBorder="false" ShowHeader="false" BodyPadding="10px">
                    <Items>
                        <f:Panel ID="Panel1" ShowHeader="false" CssClass="" ShowBorder="false" Layout="Column" runat="server">
                            <Items>
                                <f:HiddenField ID="hfFormID" runat="server"></f:HiddenField>
                                <f:HiddenField ID="hfFormTOTAL_ITEM_NAME" runat="server"></f:HiddenField>
                                <f:HiddenField ID="hfFormTOTAL_ITEM_CODE" runat="server"></f:HiddenField>
                                <f:TextBox ID="tbxFormTOTAL_ITEM_NAME" Width="310px" Label="条目名称" runat="server" Required="true" ShowRedStar="true"
                                    AutoPostBack="true" OnTextChanged="tbxFormTOTAL_ITEM_NAME_TextChanged">
                                </f:TextBox>
                                <f:TextBox ID="tbxFormTOTAL_ITEM_CODE" Width="310px" MarginLeft="20px" Label="条目编码" runat="server" Required="true" ShowRedStar="true"></f:TextBox>
                            </Items>
                        </f:Panel>
                    </Items>
                    <Items>
                        <f:Panel ID="Panel4" ShowHeader="false" CssClass="" ShowBorder="false" Layout="Column" runat="server">
                            <Items>
                                <f:TextBox ID="tbxFormTOTAL_ITEM_SEQ" Width="310px" Label="条目排序" runat="server" Required="true" ShowRedStar="true"></f:TextBox>
                                <f:DropDownList ID="ddlFormTOTAL_ITEM_TYPE" Width="310px" MarginLeft="20px" Label="条目类别" AutoSelectFirstItem="true" runat="server">
                                    <f:ListItem Text="发款项" Value="1" />
                                    <f:ListItem Text="扣款项" Value="0" />
                                </f:DropDownList>
                            </Items>
                        </f:Panel>
                    </Items>
                    <Items>
                        <f:Panel ID="Panel2" ShowHeader="false" CssClass="" ShowBorder="false" Layout="Column" runat="server">
                            <Items>
                               <f:CheckBoxList ID="chlFormSALARY_ITEMS" Hidden="true" Label="发款项" ColumnNumber="3" ColumnVertical="true" runat="server">
                                </f:CheckBoxList>
                                  <f:CheckBoxList ID="chlFormDEDUCT_ITEMS" Hidden="true" Label="扣款项" ColumnNumber="3" ColumnVertical="true" runat="server">
                                </f:CheckBoxList>
                            </Items>
                        </f:Panel>
                    </Items>
                    <Items>
                        <f:Panel ID="Panel6" ShowHeader="false" CssClass="" ShowBorder="false" Layout="Column" runat="server">
                            <Items>
                                <f:TextArea runat="server" Label="条目备注" ID="tbxFormTOTAL_ITEM_REMARK" />
                            </Items>
                        </f:Panel>
                    </Items>
                    <Toolbars>
                        <f:Toolbar ID="Toolbar1" Position="Bottom" ToolbarAlign="Right" runat="server">
                            <Items>
                                <f:Button ID="btnSave"
                                    Icon="SystemSave" runat="server" Text="保存数据" ValidateForms="SimpleForm1" OnClick="btnSave_Click">
                                </f:Button>
                            </Items>
                        </f:Toolbar>
                    </Toolbars>
                </f:SimpleForm>
            </Items>
        </f:Window>
        <br />
        <br />
        <br />
    </form>
    <script src="../res/js/ApprovalButton.js"></script>
    <script src="../res/third-party/my97/WdatePicker.js" type="text/javascript"></script>
    <script>
        var windowClientID = '<%= Window1.ClientID %>';
        var GridSalaryClientID = '<%= GridSalary.ClientID %>';
        var GridDeductClientID = '<%= GridDeduct.ClientID %>';
        var btnSaveClientID = '<%= btnSave.ClientID %>';
        var formClientID = '<%= SimpleForm1.ClientID %>';
        var hfFormIDClientID = '<%= hfFormID.ClientID %>';
        var hfFormTOTAL_ITEM_NAMEClientID = '<%= hfFormTOTAL_ITEM_NAME.ClientID %>';
        var hfFormTOTAL_ITEM_CODEClientID = '<%= hfFormTOTAL_ITEM_CODE.ClientID %>';
        var tbxFormTOTAL_ITEM_NAMEClientID = '<%= tbxFormTOTAL_ITEM_NAME.ClientID %>';
        var tbxFormTOTAL_ITEM_CODEClientID = '<%= tbxFormTOTAL_ITEM_CODE.ClientID %>';
        var tbxFormTOTAL_ITEM_SEQClientID = '<%= tbxFormTOTAL_ITEM_SEQ.ClientID %>';
        var ddlFormTOTAL_ITEM_TYPEClientID = '<%= ddlFormTOTAL_ITEM_TYPE.ClientID %>';
        var tbxFormTOTAL_ITEM_REMARKClientID = '<%= tbxFormTOTAL_ITEM_REMARK.ClientID %>';
        var chlFormSALARY_ITEMSClientID = '<%= chlFormSALARY_ITEMS.ClientID %>';
        var chlFormDEDUCT_ITEMSClientID = '<%= chlFormDEDUCT_ITEMS.ClientID %>';
        var tab1ClientID = '<%= Tab1.ClientID %>';
        var tab2ClientID = '<%= Tab2.ClientID %>';
        var tabSelValue = "1";

        function onTabChange(event, tab) {
            // 如果激活的是第一个选项卡，则重新加载其中的IFrame
            if (tab.id === tab1ClientID) {
                tabSelValue = "1";
            }
             if (tab.id === tab2ClientID) {
                tabSelValue = "0";
            }
        }
        function onNewButtonClick(event) {
            // 重置表单字段
            F(formClientID).reset();
            F(hfFormIDClientID).setValue(null);
            F(hfFormTOTAL_ITEM_NAMEClientID).setValue(null);
            F(hfFormTOTAL_ITEM_CODEClientID).setValue(null);
            if (tabSelValue == "1") {
                F(chlFormSALARY_ITEMSClientID).show();
                F(chlFormDEDUCT_ITEMSClientID).hide();
                F(ddlFormTOTAL_ITEM_TYPEClientID).setValue("1");
            }
            if (tabSelValue == "0") {
                F(chlFormSALARY_ITEMSClientID).hide();
                F(chlFormDEDUCT_ITEMSClientID).show();
                F(ddlFormTOTAL_ITEM_TYPEClientID).setValue("0");
            }
            

            // 弹出窗体
            F(windowClientID).show();
            F(windowClientID).setTitle('新增数据');
        }
        function showEditSalaryWindow(rowId) {
            var grid = F(GridSalaryClientID);

            // 如果传入参数为空，则获取当前选中行
            if (!rowId) {
                var selectedRowIds = grid.getSelectedRows();
                if (!selectedRowIds.length) {
                    F.alert('请至少选择一项！');
                    return;
                }

                rowId = selectedRowIds[0];
            }
            F(windowClientID).setTitle('编辑数据');
            // 当前行数据
            var rowValue = grid.getRowValue(rowId);
            F(hfFormIDClientID).setValue(rowId);
            F(hfFormTOTAL_ITEM_NAMEClientID).setValue(rowValue['TOTAL_ITEM_NAME']);
            F(hfFormTOTAL_ITEM_CODEClientID).setValue(rowValue['TOTAL_ITEM_CODE']);
            F(tbxFormTOTAL_ITEM_NAMEClientID).setValue(rowValue['TOTAL_ITEM_NAME']);
            F(tbxFormTOTAL_ITEM_CODEClientID).setValue(rowValue['TOTAL_ITEM_CODE']);
            F(tbxFormTOTAL_ITEM_SEQClientID).setValue(rowValue['TOTAL_ITEM_SEQ']);
            F(ddlFormTOTAL_ITEM_TYPEClientID).setValue(rowValue['TOTAL_ITEM_TYPE']);
            F(tbxFormTOTAL_ITEM_REMARKClientID).setValue(rowValue['TOTAL_ITEM_REMARK']);
            var mappingValue = rowValue['TOTAL_ITEM_MAPPING'].split(',');
            if (rowValue['TOTAL_ITEM_TYPE'] == "1") {
                F(chlFormSALARY_ITEMSClientID).show();
                F(chlFormDEDUCT_ITEMSClientID).hide();
                F(chlFormSALARY_ITEMSClientID).setValue(mappingValue);
            }
            if (rowValue['TOTAL_ITEM_TYPE'] == "0") {
                F(chlFormSALARY_ITEMSClientID).hide();
                F(chlFormDEDUCT_ITEMSClientID).show();
                F(chlFormDEDUCT_ITEMSClientID).setValue(mappingValue);
            }

            // 弹出新增窗体
            F(windowClientID).show();
        }
        function showEditDeductWindow(rowId) {
            var grid = F(GridDeductClientID);

            // 如果传入参数为空，则获取当前选中行
            if (!rowId) {
                var selectedRowIds = grid.getSelectedRows();
                if (!selectedRowIds.length) {
                    F.alert('请至少选择一项！');
                    return;
                }

                rowId = selectedRowIds[0];
            }
            F(windowClientID).setTitle('编辑数据');
            // 当前行数据
            var rowValue = grid.getRowValue(rowId);
            F(hfFormIDClientID).setValue(rowId);
            F(hfFormTOTAL_ITEM_NAMEClientID).setValue(rowValue['TOTAL_ITEM_NAME']);
            F(hfFormTOTAL_ITEM_CODEClientID).setValue(rowValue['TOTAL_ITEM_CODE']);
            F(tbxFormTOTAL_ITEM_NAMEClientID).setValue(rowValue['TOTAL_ITEM_NAME']);
            F(tbxFormTOTAL_ITEM_CODEClientID).setValue(rowValue['TOTAL_ITEM_CODE']);
            F(tbxFormTOTAL_ITEM_SEQClientID).setValue(rowValue['TOTAL_ITEM_SEQ']);
            F(ddlFormTOTAL_ITEM_TYPEClientID).setValue(rowValue['TOTAL_ITEM_TYPE']);
            F(tbxFormTOTAL_ITEM_REMARKClientID).setValue(rowValue['TOTAL_ITEM_REMARK']);
            var mappingValue = rowValue['TOTAL_ITEM_MAPPING'].split(',');
            if (rowValue['TOTAL_ITEM_TYPE'] == "1") {
                F(chlFormSALARY_ITEMSClientID).show();
                F(chlFormDEDUCT_ITEMSClientID).hide();
                F(chlFormSALARY_ITEMSClientID).setValue(mappingValue);
            }
            if (rowValue['TOTAL_ITEM_TYPE'] == "0") {
                F(chlFormSALARY_ITEMSClientID).hide();
                F(chlFormDEDUCT_ITEMSClientID).show();
                F(chlFormDEDUCT_ITEMSClientID).setValue(mappingValue);
            }

            // 弹出新增窗体
            F(windowClientID).show();
        }

    </script>
</body>
</html>
